package lab13;

public class Animal {
	
	private String name;
	private int age;
	private double weight;
	private boolean isDangerous;
	
	@Override
	public boolean equals (Object other) {
		if (other == null) return false;
		if (other == this) return true;
		if (!(other instanceof Animal)) return false;
		Animal otherAnimal = (Animal)other;
		return (this.name==otherAnimal.name);
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		if (name != null && name != "")
			this.name = name;
	}

	/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * @param age
	 *            the age to set
	 */
	public void setAge(int age) {
		if (age >= 0)
			this.age = age;
	}

	/**
	 * @return the weight
	 */
	public double getWeight() {
		return weight;
	}

	/**
	 * @param weight
	 *            the weight to set
	 */
	public void setWeight(double weight) {
		if (weight > 0)
			this.weight = weight;
	}

	/**
	 * @return the isDangerous
	 */
	public boolean isDangerous() {
		return isDangerous;
	}

	/**
	 * @param isDangerous
	 *            the isDangerous to set
	 */
	public void setDangerous(boolean isDangerous) {
		this.isDangerous = isDangerous;
	}

	protected void eat() {
		System.out.println(name + " eating...");
	}

	protected void breath() {
		System.out.println(name + " breathing...");
	}

	public Animal(String name, int age, double weight, boolean isDangerous) {
		super();
		this.name = name;
		this.age = age;
		this.weight = weight;
		this.isDangerous = isDangerous;
	}

	public Animal() {
		this("Unnamed", 0, 4.0, true);
	}

	public Animal(String name) {
		this(name, 0, 4.0, true);
	}

	@Override
	public String toString() {
		return "Animal [name=" + name + ", age=" + age + ", weight=" + weight
				+ ", isDangerous=" + isDangerous + "]";
	}

}